#include "PlayState.h"

CPlayState::CPlayState()
{
	//ctor
	
	m_pGameWorld = 0;
	
}

CPlayState::~CPlayState()
{
	//dtor
	
	if (m_pGameWorld)
		delete m_pGameWorld;
	
}

CPlayState::enter()
{
	
	//Create the Ogre scene manager
	m_pSceneMgr = m_pGameManager->getOgreRoot()->getSceneManager(Ogre::ST_GENERIC);
	
	///////////////////////
	//Setup the main camera
	///////////////////////
	// Create the camera
	m_pCamera = m_pSceneMgr->createCamera("MainCam");
	// Position it at the origin.
	m_pCamera->setPosition(Ogre::Vector3(0, 0, 0));
	// Look back along -Z
	m_pCamera->lookAt(Ogre::Vector3(0,0,-300));
	m_pCamera->setNearClipDistance(0.5);
	
	// Create one viewport, entire window
	Ogre::Viewport* pViewPort = m_pGameManager->getOgreWindow()->addViewport(m_pCamera);
	pViewPort->setBackgroundColour(Ogre::ColourValue(1,1,1));
	// Alter the camera aspect ratio to match the viewport
	m_pCamera->setAspectRatio(Ogre::Real(pViewPort->getActualWidth()) / Ogre::Real(pViewPort->getActualHeight()));
	
	//Create an instance of a game world
	m_pGameWorld = new CGameWorld();
	
	//Call the overridden createScene function in the derived game state class
	createScene();
	
};